package com.gxpt.app.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.gxpt.app.AppUtils;
import com.gxpt.app.Constant;
import com.gxpt.app.R;
import com.gxpt.app.base.ListBaseAdapter;
import com.gxpt.app.base.SuperViewHolder;
import com.gxpt.app.bean.hotgoods_bean;
import com.gxpt.app.bean.newlist_bean;
import com.utils.ScreenUtils;
import com.utils.picasso.PicassoUtils;

/**
 * Created by Lzx on 2016/12/30.
 */

public class hotgoods_Adapter extends ListBaseAdapter<hotgoods_bean.hotgoods> {

    //列表图片
    int pic_view_width = 0;
    int pic_view_hight = 0;
    Context context;
    public hotgoods_Adapter(Context context) {
        super(context);
        this.context = context;
        int Sviewwidth  = ScreenUtils.getScreenWidth(context);//
        pic_view_width  = Sviewwidth-AppUtils.dip2px(context,10*2);
        pic_view_hight  = pic_view_width/16*9;

//        Logger.i("屏幕 = " + Sviewwidth);
//        Logger.i("宽 = " + pic_view_width);
//        Logger.i("高 = " + pic_view_hight);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_mall_index_list2;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        hotgoods_bean.hotgoods item = mDataList.get(position);

        TextView txt_title = holder.getView(R.id.txt_title);
        txt_title.setText(item.goods_name);

        TextView txt_price = holder.getView(R.id.txt_price);
        txt_price.append(item.sell_price);

        TextView txt_count = holder.getView(R.id.txt_count);
        txt_count.setText(item.buy_num);
        txt_count.append(context.getString(R.string.txt_goumai));

        ImageView pic_url= holder.getView(R.id.img_1);
        if(item.thumb.isEmpty()){
            PicassoUtils.Picasso_displayImage(context,R.mipmap.ic_launcher,pic_view_width,pic_view_hight,pic_url);
        }else{
            PicassoUtils.Picasso_displayImage(context,Constant.IP + item.thumb,pic_view_width,pic_view_hight,pic_url);
        }
    }
}
